home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / 1.2 / scripts / alien-glow-button.scm.z / alien-glow-button.scm
Text File  |  2002-07-08  |  5KB  |  147 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed button
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on code from Frederico Mena Quintero (Quartic)
  8. ; federico@nuclecu.unam.mx
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ; GNU General Public License for more details.
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (text-width extents)
  24.   (car extents))
  25.  
  26. (define (text-height extents)
  27.   (cadr extents))
  28.  
  29. (define (text-ascent extents)
  30.   (caddr extents))
  31.  
  32. (define (text-descent extents)
  33.   (cadr (cddr extents)))
  34.  
  35. (define (blend-bumpmap img drawable x1 y1 x2 y2)
  36.   (gimp-blend drawable
  37.           FG-BG-RGB
  38.           DARKEN-ONLY
  39.           LINEAR
  40.           100
  41.           0
  42.           REPEAT-NONE
  43.           FALSE
  44.           0
  45.           0
  46.           x1
  47.           y1
  48.           x2
  49.           y2))
  50.  
  51. (define (script-fu-alien-glow-button text
  52.                 font
  53.                 size
  54.                 text-color
  55.                 glow-color
  56.                 bg-color
  57.                 padding
  58.                 glow-radius
  59.                 flatten)
  60.   (let* ((old-fg-color (car (gimp-palette-get-foreground)))
  61.      (old-bg-color (car (gimp-palette-get-background)))
  62.      (text-extents (gimp-text-get-extents-fontname text
  63.                                size
  64.                                PIXELS
  65.                                font))
  66.      (ascent (text-ascent text-extents))
  67.      (descent (text-descent text-extents))
  68.      
  69.      (img-width (+ (* 2  padding)
  70.                (- (text-width text-extents)
  71.               (text-width (gimp-text-get-extents-fontname " "
  72.                                       size
  73.                                       PIXELS
  74.                                       font)))))
  75.      (img-height (+ (* 2 padding)
  76.             (+ ascent descent)))
  77.      (layer-height img-height)
  78.      (layer-width img-width)
  79.      (img-width (+ img-width glow-radius))
  80.      (img-height (+ img-height glow-radius))
  81.      (img (car (gimp-image-new  img-width   img-height  RGB)))
  82.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Background" 100 NORMAL)))
  83.      (glow-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Glow" 100 NORMAL)))
  84.      (button-layer (car (gimp-layer-new img layer-width layer-height RGBA_IMAGE "Button" 100 NORMAL))))
  85.  
  86.     (gimp-image-undo-disable img)
  87.  
  88.     ; Create bumpmap layer
  89.     
  90.     (gimp-image-add-layer img bg-layer -1)
  91.     (gimp-palette-set-foreground '(0 0 0))
  92.     (gimp-palette-set-background bg-color)
  93.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  94.     (gimp-image-add-layer img glow-layer -1)
  95.  
  96.     ; Create text layer
  97.  
  98.     (gimp-image-add-layer img button-layer -1)
  99.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  100.     (gimp-selection-none img)
  101.     (gimp-rect-select img 0 0 img-width img-height REPLACE FALSE 0)
  102.     (gimp-palette-set-foreground '(100 100 100))
  103.     (gimp-palette-set-background '(0 0 0))
  104.     (gimp-blend button-layer FG-BG-RGB NORMAL SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE 0 0 0 0 img-height img-width)
  105.     (gimp-edit-clear glow-layer)
  106.     (gimp-rect-select img (/ glow-radius 4) (/ glow-radius 4) (- img-width (/ glow-radius 2)) (- img-height (/ glow-radius 2)) REPLACE FALSE 0 )
  107.     (gimp-palette-set-foreground glow-color)
  108.     (gimp-edit-fill glow-layer FG-IMAGE-FILL)
  109.     (gimp-selection-none img)
  110.     (plug-in-gauss-rle 1 img glow-layer glow-radius TRUE TRUE)
  111.     (gimp-palette-set-foreground text-color)
  112.     (let ((textl (car (gimp-text-fontname
  113.                img -1 0 0 text 0 TRUE size PIXELS font))))
  114.       (gimp-layer-set-offsets textl
  115.                   (+  padding (/ glow-radius 2))
  116.                   (+ (+ padding descent) (/ glow-radius 2))))
  117.     ; Done
  118.     (gimp-selection-none img)
  119.     (gimp-palette-set-foreground old-fg-color)
  120.     (gimp-palette-set-background old-bg-color)
  121.     (gimp-image-undo-enable img)
  122.     (if (= flatten TRUE)
  123.     (gimp-image-flatten img))
  124.     (gimp-display-new img)))
  125.  
  126. ; Register!
  127.  
  128. (script-fu-register "script-fu-alien-glow-button"
  129.             _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Alien Glow/Button..."
  130.             "Button with an eerie glow"
  131.             "Adrian Likins"
  132.             "Adrian Likins"
  133.             "July 1997"
  134.             ""
  135.             SF-STRING _"Text" "Hello world!"
  136.             SF-FONT   _"Font" "-*-futura_poster-*-*-*-*-22-*-*-*-*-*-*-*"
  137.             SF-ADJUSTMENT _"Font Size (pixels)" '(22 2 100 1 1 0 1)
  138.             SF-COLOR      _"Text Color" '(0 0 0)
  139.             SF-COLOR      _"Glow Color" '(63 252 0)
  140.             SF-COLOR      _"Background Color" '(0 0 0)
  141.             SF-ADJUSTMENT _"Padding" '(6 1 100 1 10 0 1)
  142.             SF-ADJUSTMENT _"Glow Radius" '(10 1 200 1 10 0 1)
  143.             SF-TOGGLE     _"Flatten Image" TRUE)
  144.